<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/6/13
 * Time: 10:53
 */
if(empty($_POST)) {

    ?>


    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>

    <form action="" enctype="multipart/form-data" method="post">
        <table border="1" align="center">
            <tr>
                <th>部门名称</th>
                <td><input type="text" name="name"></td>
            </tr>
            <tr>
                <th>部门描述</th>
                <td><input type="text" name="description"></td>
            </tr>
            <tr align="center">
                <td colspan="2"><input type="submit" value="提交"></td>
            </tr>
        </table>
    </form>

    </body>
    </html>


    <?php
}else {
    include_once('conn.php');

    $name = $_POST['name'];
    $description = $_POST['description'];


    $sql = "insert into `department` value (null,'$name','$description')";

    $pd = mysqli_query($conn, $sql);

    if ($pd) {
        header('location:index.php');
//        echo "<script>alert('成功');history.go(-1);</script>>";
    }else{
        echo "失败了"."<a href='index.php'>回到首页</a>";
    }

}








